import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ResponseVO, ResponseForm, ResponseQuery } from '@/api/system/response/types';

/**
 * 查询问卷收集列表
 * @param query
 * @returns {*}
 */

export const listResponse = (query?: ResponseQuery): AxiosPromise<ResponseVO[]> => {
  return request({
    url: '/system/response/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询问卷收集详细
 * @param responseId
 */
export const getResponse = (responseId: string | number): AxiosPromise<ResponseVO> => {
  return request({
    url: '/system/response/' + responseId,
    method: 'get'
  });
};

/**
 * 新增问卷收集
 * @param data
 */
export const addResponse = (data: ResponseForm) => {
  return request({
    url: '/system/response',
    method: 'post',
    data: data
  });
};

/**
 * 修改问卷收集
 * @param data
 */
export const updateResponse = (data: ResponseForm) => {
  return request({
    url: '/system/response',
    method: 'put',
    data: data
  });
};

/**
 * 删除问卷收集
 * @param responseId
 */
export const delResponse = (responseId: string | number | Array<string | number>) => {
  return request({
    url: '/system/response/' + responseId,
    method: 'delete'
  });
};
